﻿using System;
using FluentNHibernate.Mapping;
using Caramel.NHibernate.Membership.Entities;

namespace Caramel.NHibernate.Membership.Mapping
{
	public class aspnet_MembershipMapping : ClassMap<aspnet_Membership>
	{
		public aspnet_MembershipMapping()
		{
			this.
				Table("aspnet_Membership");

			this.
				CompositeId().
				KeyReference(e => e.Application, "ApplicationId").
				KeyReference(e => e.User, "UserId");

			this.
				Map(e => e.Password).
				Length(128).
				Not.
				Nullable();

			this.
				Map(e => e.PasswordFormat).
				Not.
				Nullable();

			this.
				Map(e => e.PasswordSalt).
				Length(128).
				Not.
				Nullable();

			this.
				Map(e => e.MobilePIN).
				Length(16).
				Nullable();

			this.
				Map(e => e.Email).
				Length(256).
				Nullable();

			this.
				Map(e => e.LoweredEmail).
				Length(256).
				Nullable();

			this.
				Map(e => e.PasswordQuestion).
				Length(256).
				Nullable();

			this.
				Map(e => e.PasswordAnswer).
				Length(128).
				Nullable();

			this.
				Map(e => e.IsApproved).
				Not.
				Nullable();

			this.
				Map(e => e.IsLockedOut).
				Not.
				Nullable();

			this.
				Map(e => e.CreateDate).
				Not.
				Nullable();

			this.
				Map(e => e.LastLoginDate).
				Not.
				Nullable();

			this.
				Map(e => e.LastPasswordChangedDate).
				Not.
				Nullable();

			this.
				Map(e => e.LastLockoutDate).
				Not.
				Nullable();

			this.
				Map(e => e.FailedPasswordAttemptCount).
				Not.
				Nullable();

			this.
				Map(e => e.FailedPasswordAttemptWindowStart).
				Not.
				Nullable();

			this.
				Map(e => e.FailedPasswordAnswerAttemptCount).
				Not.
				Nullable();

			this.
				Map(e => e.FailedPasswordAnswerAttemptWindowStart).
				Not.
				Nullable();

			this.
				Map(e => e.Comment).
				Nullable();

			this.
				References(e => e.Application).
				Column("ApplicationId").
				Not.
				Nullable();

			this.
				References(e => e.User).
				Column("UserId").
				Not.
				Nullable();
		}
	}
}
